package com.dingwen.treasure.security.exception;

import com.dingwen.treasure.base.exception.BaseExceptionHandler;
import com.dingwen.treasure.base.pojo.vo.Result;
import com.dingwen.treasure.base.pojo.vo.ResultGenerator;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;


/**
 * security 授权异常 403： 此处继续抛出交由TreasureAccessDeniedHandler处理
 * 　@author dingwen
 * 　@date 2022/6/19
 */
@Component("org.springframework.security.access.AccessDeniedException")
public class AccessDeniedExceptionHandlerImpl extends BaseExceptionHandler {

    /**
     * 根据异常构建统一返回结果
     *
     * @param exception
     * @return result
     */
    @Override
    public Result buildResultByException(Exception exception) {
        return ResultGenerator.genFailureResult(exception.getMessage(), HttpStatus.FORBIDDEN.value());
    }
}
